<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="br.com.unip.modelo.Funcionario,br.com.unip.persistencia.FuncionarioDao"%>
<%@ page import="java.util.List"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Funcionário</title>
</head>

<style>
a {
	color: blue;
	text-decoration: none;
}
</style>

<script type="text/javascript">
function deletar(id) {
	var confirma = confirm("Deletar?");
	if(confirma){
		window.location = "controle.jsp?action=deletar&id=" + id;
	}
}
</script>

<body>
	<h2>Funcionário</h2>
	<table width="100%" border="1" bordercolor="#000" cellpadding="0"
		cellspacing="0">
		<tr>
			<th>ID</th>
			<th>Nome</th>
			<th>Data de nascimento</th>
			<th>Salário</th>
			<th>Departamento</th>
			<th>Supervisor</th>
			<th colspan="2">Ações</th>
		</tr>
		<%
			try {
				FuncionarioDao fd = new FuncionarioDao();
				List<Funcionario> listar = fd.listar();

				for (Funcionario rp : listar) {
		%>
		<tr>
			<td align="right"><%=rp.getCod_func()%></td>
			<td align="center"><%=rp.getNome()%></td>
			<td align="center"><%=rp.getDataNascimento()%></td>
			<td align="right"><%=rp.getSalario()%></td>
			<td align="right"><%=rp.getNumeroDepartamento()%></td>
			<td align="right"><%=rp.getCodigoSupervisor()%></td>
			<td align="center"><% out.print("<a href=atualizar.jsp?action=atualizar&id="+ rp.getCod_func() +">Atualizar</a>"); %></td>
			<td align="center"><a href="#" onclick="deletar(<%= rp.getCod_func() %>);">Deletar</a></td>
		</tr>
		<%
			}
			} catch (Exception e) {
				out.print("Erro" + e);
			}
		%>
	</table>
	<br />
	<a href="novo.jsp">Inserir</a><br /><br /> 
	<a href="/projetoUnipJSP/index.html">Home</a> | <a href="/projetoUnipJSP/projeto/index.jsp">Projeto</a> | <a href="/projetoUnipJSP/departamento/index.jsp">Departamento</a>
	<br /><br />
	<div style="border: 1px solid #555555; display: block;">${msg}</div>
</body>
</html>